import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CardCollageVO, CardCollageFormVo, CardCollageQuery } from '@/api/workflow/cardCollage/types';

/**
 * 查询拼团管理列表
 * @param query
 * @returns {*}
 */

export const listCardCollage = (query?: CardCollageQuery): AxiosPromise<CardCollageVO[]> => {
  return request({
    url: '/system/collage/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询拼团管理详细
 * @param id
 */
export const getCardCollage = (id: string | number) => {
  return request({
    url: '/system/collage/queryCollageInfoByPc/' + id,
    method: 'get'
  });
};

/**
 * 新增拼团管理
 * @param data
 */
export const addCardCollage = (data: CardCollageFormVo) => {
  return request({
    url: '/system/collage/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改拼团管理
 * @param data
 */
export const updateCardCollage = (data: CardCollageFormVo) => {
  return request({
    url: '/system/collage/edit',
    method: 'post',
    data: data
  });
};

/**
 * 删除拼团管理
 * @param id
 */
export const delCardCollage = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/collage/' + id,
    method: 'delete'
  });
};
// 计算商品份数 lot数
// /collage/getCardSeriesLotCount?cardCategoryId=&playWay=&collageModule=
export const getCardSeriesLotCount = (query: any) => {
  return request({
    url: '/system/collage/getCardSeriesLotCount',
    method: 'get',
    params: query
  });
};
// 计算价格
// /collage/calculateTotalPrice?price=1&count=1
export const calculateTotalPrice = (query: any) => {
  return request({
    url: '/system/collage/calculateTotalPrice',
    method: 'post',
    params: query
  });
};

export const sumCardCollageTotalMoney = (query: any) => {
  return request({
    url: '/system/collage/sumCardCollageTotalMoney',
    method: 'post',
    data: query
  });
};

export const getGourpTeamByCardCategory = (query: any) => {
  return request({
    url: '/system/collage/getGourpTeamByCardCategory',
    method: 'get',
    params: query
  });
};

export const openApprovalCollageState = (collageId: string | number) => {
  return request({
    url: '/system/collage/openApprovalCollageState?collageId=' + collageId,
    method: 'post',
  });
};

export const copyCardCollage = (id: string | number) => {
  return request({
    url: '/system/collage/copyCardCollage/' + id,
    method: 'post',
  });
};

// /collage/shelfCollageState?collageId=1
export const shelfCollageState = (collageId: string | number) => {
  return request({
    url: '/system/collage/shelfCollageState?collageId=' + collageId,
    method: 'post',
  });
};
// /collage/againChangeCollageState
export const againChangeCollageState = (query: any) => {
  return request({
    url: '/system/collage/againChangeCollageState',
    method: 'post',
    data: query
  });
};


export const getLockUserCollageList = (query: any) => {
  return request({
    url: '/system/collage/getLockUserCollageList',
    method: 'get',
    params: query
  });
};

export const removeLockUserCollage = (query: any) => {
  return request({
    url: '/system/collage/removeLockUserCollage',
    method: 'post',
    params: query
  });
};

export const cardCollageRankingList = (cardCollageId: any) => {
  return request({
    url: '/system/collage/cardCollageRankingList/' + cardCollageId,
    method: 'get'
  });
};

export const queryCollageUserInfo = (query: any) => {
  return request({
    url: '/system/collage/queryCollageUserInfo/' + query.collageId,
    method: 'get',
    params: query
  });
};

/**
 * 查询卡密用户信息
 * @param query
 */
export const queryCollageUserCarmiInfo = (query: any) => {
  return request({
    url: '/system/collage/queryCollageUserCarmiInfo',
    method: 'get',
    params: query
  });
};

export const openGroupRandom = (query: any) => {
  return request({
    url: '/system/collage/openGroupRandom/' + query,
    method: 'post'
  });
};

export const isExitCollage = (query: any) => {
  return request({
    url: '/system/collage/isExitCollage',
    method: 'get'
  });
};

export const openCollagePosition = (query: any) => {
  return request({
    url: '/system/collage/openCollagePosition',
    method: 'get',
    params: query
  });
};

export const isAllExitCollage = () => {
  return request({
    url: '/system/collage/isExitAllCollage',
    method: 'get'
  });
};

export const openAllCollagePosition = (query: any) => {
  return request({
    url: '/system/collage/openCollageAllPosition',
    method: 'get',
    params: query
  });
};

export const batchCopyCardCollage = (formData: any) => {
  return request({
    url: '/system/collage/batchCopyCardCollage',
    method: 'post',
    data: formData
  });
};

/**
 * 批量审核拼团管理
 * @param id
 */
export const batchOpenApprovalCollageState = (data: any) => {
  return request({
    url: '/system/collage/batchOpenApprovalCollageState',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json'
    }
  });
};
